//webpack4写法
//弹框方式，弹出时执行点击操作
export function popView(select, showPopup, x, y) {
    $(select).click(function() {
        $(".Popup:not(.no-close)").hide();
        $(showPopup).css({
            left: x,
            top: y,
        }).fadeIn(500);
    });
}

//弹框方式，在屏幕中间弹窗，弹出时不进行操作
export function popViewCenter(showPopup) {
    $(".Popup:not(.no-close)").hide();
    $(showPopup).css({
    }).fadeIn(500);
}

//弹框方式，弹出时执行点击操作
export function popViewClick(select, showPopup, x, y) {
    $(select).click(function() {
        $(".Popup:not(.no-close)").hide();
        $(showPopup).css({
            left: x,
            top: y,
        }).fadeIn(500);
    });
}

//二级弹框 - 单行翻页
export function popArScroll(sbtn, lineH) {
    $(sbtn).children(".next").click(function(e) {
        let that = e.currentTarget;
        var sTop = $(that).parents(".pop-vlist-btn").siblings(".pop-vlist-scroll").scrollTop() + lineH;
        $(that).parents(".pop-vlist-btn").siblings(".pop-vlist-scroll").scrollTop(sTop);
    });
    $(sbtn).children(".prev").click(function(e) {
        let that = e.currentTarget;
        var sTop = $(that).parents(".pop-vlist-btn").siblings(".pop-vlist-scroll").scrollTop() - lineH;
        $(that).parents(".pop-vlist-btn").siblings(".pop-vlist-scroll").scrollTop(sTop);
    });
}

//表格滚动 - setInterval
export function tableScroll(tbox) {
    var corStr = 100;
    var corEnd = 100;
    var tbx = $(tbox);
    var tsTop = 0;
    var speed = 2;
    var actDo = setInterval(tbsc,50);
    function tbsc() {
        var boxH = tbx.height();
        var tabH = tbx.children().height();
        var maxS = boxH - tabH - corEnd;
        if(boxH < tabH) {
            tsTop -= speed;
            if(maxS > tsTop) {
                tsTop = corStr;
            }
        } else {
            tsTop = 0;
        }
        tbx.children().css({
            marginTop: tsTop
        });
    }
    tbx.hover(function(){
        clearInterval(actDo);
    },function(){
        actDo = setInterval(tbsc,50);
    });
}

//active
export function actSil(actPr) {
    $(actPr).children().click(function(){
        $(this).addClass("active").siblings().removeClass("active");
    });
}

//顶部切换
export function relTabs(rbtn, rcon){
    $(rbtn).children().click(function(){
        var tNub = $(this).index();
        $(rcon).children().hide().eq(tNub).show();
    });
}
